#!groovy



//调用Jenkins中定义的选项参数 名称和Jenkins中定义的保持一致
String buildshell="${env.buildshell}"
pipeline{
    agent any
    stages{
        stage("mvnbuild"){
            steps{
                script{
                    mvnHome=tool "mvn"
                    sh "${mvnHome}/bin/mvn ${buildshell} " //调用变量
                }
            }
        }
        stage("antbuild"){
            steps{
                script{
                    try{          //添加异常处理,防止阻塞下方stage的执行
                        antHome=tool "ant"
                        sh "${antHome}/bin/ant ${buildshell}"
                    }catch(e){
                        println(e)
                    }
                }
            }
        }
        stage("gradlebuild"){
            steps{
                script{
                    gradleHome=tool "gradle"
                    sh "${gradleHome}/bin/gradle ${buildshell}"
                }
            }
        }
        stage("npmbuild"){
            steps{
                script{
                    npmHome=tool "npm"
                    sh "${npmHome}/bin/npm ${buildshell}"
                    sh "${npmHome}/bin/node ${buildshell}"
                }
            }
        }
    }
}